/*
 * @Author: anxia.ack anchenkai@come-future.com
 * @Date: 2025-04-14 00:05:44
 * @LastEditors: anxia.ack anchenkai@come-future.com
 * @LastEditTime: 2025-04-21 22:05:30
 * @FilePath: /free-learning/src/api/course/course-chapters/index.ts
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
import request from "@/utils/request";
import type { CourseChapters, CourseChaptersParams, CourseChaptersSortVO } from "./type";
const COURSE_CHAPTERS_BASE_URL = "/api/v1/course/chapters";
export const getCourseChapters = (params: CourseChaptersParams) => {
  return request<any, MyPageResult<CourseChapters[]>>({
    url: `${COURSE_CHAPTERS_BASE_URL}/page`,
    method: "post",
    data: params,
  });
};

export const addCourseChapters = (params: CourseChapters): Promise<CourseChapters> => {
  return request({
    url: `${COURSE_CHAPTERS_BASE_URL}/add`,
    method: "post",
    data: params,
  });
};

export const updateCourseChapters = (params: CourseChapters) => {
  return request<boolean>({
    url: `${COURSE_CHAPTERS_BASE_URL}/update`,
    method: "post",
    data: params,
  });
};

export const deleteCourseChapters = (id: number) => {
  return request<boolean>({
    url: `${COURSE_CHAPTERS_BASE_URL}/delete/${id}`,
    method: "post",
  });
};

export const getCourseChaptersSort = (id: number) => {
  return request<any, CourseChaptersSortVO[]>({
    url: `${COURSE_CHAPTERS_BASE_URL}/sortChaptersList/${id}`,
    method: "get",
  });
};

export const updateCourseChaptersSort = (params: CourseChaptersSortVO[]) => {
  return request<boolean>({
    url: `${COURSE_CHAPTERS_BASE_URL}/sortChapters`,
    method: "post",
    data: params,
  });
};
